package bean;

public class LoggedUser {

	private int id;
	private String userName;
	private String password;
	private UserType userType;
	
	public int getId() {
		return id;
	}

	public String getUserName() {
		return userName;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public UserType getUserType()
	{
		return userType;
	}
	public LoggedUser(int id,String userName,String password,UserType type)
	{
		this.id = id;
		this.userName = userName;
		this.password = password;
		this.userType = type;
	}
	
	public boolean isCustomer(){
		return this.userType == UserType.Customer;
	}
	
	public static LoggedUser createFromCustomer(Customer customer)
	{
		return new LoggedUser(customer.getId(),customer.getUsername(),customer.getPassword(),UserType.Customer);
	}
	
	public static LoggedUser createFromEmployee(Employee employee)
	{
		return new LoggedUser(employee.getId(),employee.getUsername(),employee.getPassword(),UserType.Employee);
	}
	
}
